package com.study.designPattern.create.singleton;

/**
 * @author ysy
 * @version 1.0
 * @Title: SingletonPatternTest
 * @Note <b>ProjectName:</b> Pre-research
 * <br><b>PackageName:</b> com.study.designPattern.create.singleton
 * <br><b>ClassName:</b>
 * <br><b>Date:</b>

 */
public class SingletonPatternTest {

    public static void main(String[] args) {
        // 2.1 懒汉模式(线程不安全)
        LazySingleton instance1 = LazySingleton.getInstance();
        instance1.whoAreU("小土狗1", 18);

        // 2.1 懒汉模式(线程安全)
        LazySafeSingleton instance2 = LazySafeSingleton.getInstance();
        instance2.whoAreU("小土狗2", 18);

        // 2.3 饿汉模式
        HungrySingleton instance3 = HungrySingleton.getInstance();
        instance3.whoAreU("小土狗3", 18);

        // 2.4 双重检验模式
        DoubleCheckSingleton instance4 = DoubleCheckSingleton.getInstance();
        instance4.whoAreU("小土狗4", 18);

        // 2.5 静态内部类模式
        StaticInnerClassSingleton instance5 = StaticInnerClassSingleton.getInstance();
        instance5.whoAreU("小土狗5", 18);

        // 2.6 枚举模式
        EnumSingleton instance6 = EnumSingleton.INSTANCE;
        instance6.whoAreU("小土狗6", 18);
    }
}
